<?php
$sub_menu = "230150";
include_once("_common.php");

auth_check($auth[$sub_menu], "r");

$is_coupon = false;
if (file_exists($g4['path']."/plugin/coupon/_config.php"))
    $is_coupon = true;

if (!$is_coupon)
    alert("쿠폰발행기 설치 후 이용하실 수 있습니다.");

include_once("{$g4['path']}/plugin/coupon/_config.php");

$g4['title'] = "쿠폰발급내역";
include_once($g4['path']."/head.sub.php");

$colspan = "5";

echo subtitle($g4['title']);
?>
<link rel="stylesheet" href="<?=$g4['admin_path']?>/admin.style.css" type="text/css">
<style>
body { padding:10px; }
</style>

<table width=100% cellpadding=0 cellspacing=1 align=center style="margin:0 auto 0 auto;">
<colgroup width=150>
<colgroup width=''>
<colgroup width=100>
<colgroup width=100>
<tr><td colspan='<?php echo $colspan?>' class='line1'></td></tr>
<tr class='bgcol1 bold col1 ht center'>
    <td> 쿠폰이름 </td>
    <td> 쿠폰내용 </td>
    <td> 발행일시 </td>
    <td> 사용일시 </td>
</tr>
<tr><td colspan='<?php echo $colspan?>' class='line2'></td></tr>
<?php
$sql = " select * from {$mw_coupon['list_table']} ";
$sql.= "  where cp_rel_table = '{$mw_cash['grade_table']}' ";
//$sql.= "    and cp_rel_id = '{$gd_id}' ";
$sql.= "    and mb_id_only = '{$mb_id}' ";
$sql.= "  order by cp_id desc ";
$qry = sql_query($sql);
for ($i=0; $list=sql_fetch_array($qry); ++$i)
{
    $info = sql_fetch(" select * from {$mw_coupon['info_table']} where cp_id = '{$list['cp_id']}' ");

    $cp_content = "포인트 ".number_format($info['cp_price'])."점 적립";
    if ($info['cp_type'] == 'c') {
        $cp_content = "{$mw_cash['cf_cash_name']} ".number_format($info['cp_price'])."{$mw_cash['cf_cash_unit']} 적립";
    }

    $cp_use_datetime = $list['cp_use_datetime'];
    if ($cp_use_datetime[0] == 0) {
        $cp_use_datetime = '-';
    }

    $class = $i%2;
?>
<tr class='list<?php echo $class?> col1 ht center'>
    <td> <?php echo $info['cp_subject']?> </td>
    <td> <?php echo $cp_content?> </td>
    <td> <?php echo $info['cp_datetime']?> </td>
    <td> <?php echo $cp_use_datetime?> </td>
</tr>
<?php }
if (!$i)
    echo "<tr> <td style='height:100px; text-align:center;' colspan='{$colspan}' class='b'> 자료가 없습니다. </td></tr>";
?>
<tr><td colspan="<?php echo $colspan?>" class="line2"></td></tr>
</table>

<div style="text-align:center; margin:20px 0 0 0;">
    <input type="button" class="btn1" value="닫     기" onclick="self.close()">
</div>

<?php

include_once ($g4['path']."/tail.sub.php");
